/**
 */
package proyecto.testcasetool.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import proyecto.testcasetool.ActionStep;
import proyecto.testcasetool.Agent;
import proyecto.testcasetool.AlternativeFlow;
import proyecto.testcasetool.InputParameter;
import proyecto.testcasetool.OutputParameter;
import proyecto.testcasetool.TestcasetoolPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Action Step</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getOutputParameter <em>Output Parameter</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getInputParameter <em>Input Parameter</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getAgent <em>Agent</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getAlternativeFlow <em>Alternative Flow</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActionStepImpl extends StepImpl implements ActionStep {
	/**
	 * The cached value of the '{@link #getOutputParameter() <em>Output Parameter</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputParameter()
	 * @generated
	 * @ordered
	 */
	protected OutputParameter outputParameter;

	/**
	 * The cached value of the '{@link #getInputParameter() <em>Input Parameter</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInputParameter()
	 * @generated
	 * @ordered
	 */
	protected EList<InputParameter> inputParameter;

	/**
	 * The cached value of the '{@link #getAgent() <em>Agent</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAgent()
	 * @generated
	 * @ordered
	 */
	protected Agent agent;

	/**
	 * The cached value of the '{@link #getAlternativeFlow() <em>Alternative Flow</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAlternativeFlow()
	 * @generated
	 * @ordered
	 */
	protected AlternativeFlow alternativeFlow;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionStepImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TestcasetoolPackage.Literals.ACTION_STEP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OutputParameter getOutputParameter() {
		if (outputParameter != null && outputParameter.eIsProxy()) {
			InternalEObject oldOutputParameter = (InternalEObject)outputParameter;
			outputParameter = (OutputParameter)eResolveProxy(oldOutputParameter);
			if (outputParameter != oldOutputParameter) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestcasetoolPackage.ACTION_STEP__OUTPUT_PARAMETER, oldOutputParameter, outputParameter));
			}
		}
		return outputParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OutputParameter basicGetOutputParameter() {
		return outputParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutputParameter(OutputParameter newOutputParameter) {
		OutputParameter oldOutputParameter = outputParameter;
		outputParameter = newOutputParameter;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__OUTPUT_PARAMETER, oldOutputParameter, outputParameter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<InputParameter> getInputParameter() {
		if (inputParameter == null) {
			inputParameter = new EObjectResolvingEList<InputParameter>(InputParameter.class, this, TestcasetoolPackage.ACTION_STEP__INPUT_PARAMETER);
		}
		return inputParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Agent getAgent() {
		if (agent != null && agent.eIsProxy()) {
			InternalEObject oldAgent = (InternalEObject)agent;
			agent = (Agent)eResolveProxy(oldAgent);
			if (agent != oldAgent) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestcasetoolPackage.ACTION_STEP__AGENT, oldAgent, agent));
			}
		}
		return agent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Agent basicGetAgent() {
		return agent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetAgent(Agent newAgent, NotificationChain msgs) {
		Agent oldAgent = agent;
		agent = newAgent;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__AGENT, oldAgent, newAgent);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAgent(Agent newAgent) {
		if (newAgent != agent) {
			NotificationChain msgs = null;
			if (agent != null)
				msgs = ((InternalEObject)agent).eInverseRemove(this, TestcasetoolPackage.AGENT__AGENT_ACTION_STEP, Agent.class, msgs);
			if (newAgent != null)
				msgs = ((InternalEObject)newAgent).eInverseAdd(this, TestcasetoolPackage.AGENT__AGENT_ACTION_STEP, Agent.class, msgs);
			msgs = basicSetAgent(newAgent, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__AGENT, newAgent, newAgent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AlternativeFlow getAlternativeFlow() {
		if (alternativeFlow != null && alternativeFlow.eIsProxy()) {
			InternalEObject oldAlternativeFlow = (InternalEObject)alternativeFlow;
			alternativeFlow = (AlternativeFlow)eResolveProxy(oldAlternativeFlow);
			if (alternativeFlow != oldAlternativeFlow) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW, oldAlternativeFlow, alternativeFlow));
			}
		}
		return alternativeFlow;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AlternativeFlow basicGetAlternativeFlow() {
		return alternativeFlow;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetAlternativeFlow(AlternativeFlow newAlternativeFlow, NotificationChain msgs) {
		AlternativeFlow oldAlternativeFlow = alternativeFlow;
		alternativeFlow = newAlternativeFlow;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW, oldAlternativeFlow, newAlternativeFlow);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAlternativeFlow(AlternativeFlow newAlternativeFlow) {
		if (newAlternativeFlow != alternativeFlow) {
			NotificationChain msgs = null;
			if (alternativeFlow != null)
				msgs = ((InternalEObject)alternativeFlow).eInverseRemove(this, TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP, AlternativeFlow.class, msgs);
			if (newAlternativeFlow != null)
				msgs = ((InternalEObject)newAlternativeFlow).eInverseAdd(this, TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP, AlternativeFlow.class, msgs);
			msgs = basicSetAlternativeFlow(newAlternativeFlow, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW, newAlternativeFlow, newAlternativeFlow));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				if (agent != null)
					msgs = ((InternalEObject)agent).eInverseRemove(this, TestcasetoolPackage.AGENT__AGENT_ACTION_STEP, Agent.class, msgs);
				return basicSetAgent((Agent)otherEnd, msgs);
			case TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW:
				if (alternativeFlow != null)
					msgs = ((InternalEObject)alternativeFlow).eInverseRemove(this, TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP, AlternativeFlow.class, msgs);
				return basicSetAlternativeFlow((AlternativeFlow)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				return basicSetAgent(null, msgs);
			case TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW:
				return basicSetAlternativeFlow(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__OUTPUT_PARAMETER:
				if (resolve) return getOutputParameter();
				return basicGetOutputParameter();
			case TestcasetoolPackage.ACTION_STEP__INPUT_PARAMETER:
				return getInputParameter();
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				if (resolve) return getAgent();
				return basicGetAgent();
			case TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW:
				if (resolve) return getAlternativeFlow();
				return basicGetAlternativeFlow();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__OUTPUT_PARAMETER:
				setOutputParameter((OutputParameter)newValue);
				return;
			case TestcasetoolPackage.ACTION_STEP__INPUT_PARAMETER:
				getInputParameter().clear();
				getInputParameter().addAll((Collection<? extends InputParameter>)newValue);
				return;
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				setAgent((Agent)newValue);
				return;
			case TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW:
				setAlternativeFlow((AlternativeFlow)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__OUTPUT_PARAMETER:
				setOutputParameter((OutputParameter)null);
				return;
			case TestcasetoolPackage.ACTION_STEP__INPUT_PARAMETER:
				getInputParameter().clear();
				return;
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				setAgent((Agent)null);
				return;
			case TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW:
				setAlternativeFlow((AlternativeFlow)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__OUTPUT_PARAMETER:
				return outputParameter != null;
			case TestcasetoolPackage.ACTION_STEP__INPUT_PARAMETER:
				return inputParameter != null && !inputParameter.isEmpty();
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				return agent != null;
			case TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW:
				return alternativeFlow != null;
		}
		return super.eIsSet(featureID);
	}

} //ActionStepImpl
